# -*-coding = utf-8 -*-

# @Time: 2021/3/31 21:25
# @Author: bistro
# @File: p90.py
# @Software: PyCharm
from typing import List


class Solution:
    def subsetsWithDup(self, nums: List[int]) -> List[List[int]]:
        if len(nums) == 1:
            return [[], nums]
        else:
            tail = nums.pop()
            results = self.subsetsWithDup(nums)
            copy_results = results[::]
            new_results = [elem + [tail] for elem in copy_results]
            for new_elem in new_results:
                new_elem.sort()
                if new_elem not in results:
                    results.append(new_elem)
            return results


"""
测试用例
s = Solution()
res = s.subsetsWithDup([4, 4, 4, 1, 4])
print(res)
"""


